/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csse3004.GD.PM;

import org.springframework.validation.Validator;
import org.springframework.validation.Errors;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
 *
 * @author s4201567 Tony Yu
 */
public class EditPartListValidator implements Validator {
    
    protected final Log logger = LogFactory.getLog(getClass());
    
    public boolean supports(Class clazz) {
        return EditPartList.class.equals(clazz);
    }
    
    public void validate(Object obj, Errors errors) {
        EditPartList epl = (EditPartList)obj;
        
        int participantId = epl.getPollUserID();
        
        if (participantId < 0) {
            errors.rejectValue("pollUserID", "errors.not-specified", null, "Value cannot be negative.");
        } else {
            logger.info("Processing...");
        }
    }
}
